package com.store.pet.petstore.activity;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.gyf.barlibrary.ImmersionBar;
import com.store.pet.petstore.R;
import com.store.pet.petstore.bean.UserBean;
import com.store.pet.petstore.util.Constant;
import com.store.pet.petstore.util.SharedPreferencesUtil;

import butterknife.BindView;

public class InformationActivity extends BaseActivity {

    @BindView(R.id.my_status)
    View myStatus;
    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.nickname)
    TextView nickname;
    @BindView(R.id.sex)
    TextView sex;
    @BindView(R.id.phone)
    TextView phone;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public int getLayoutID() {
        return R.layout.activity_information;
    }

    @Override
    public void init(Bundle savedInstanceState) {
        //沉浸式标题栏
        ImmersionBar.with(this).statusBarDarkFont(true).init();
        takeLinearStatusBar(myStatus);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setNavigationIcon(R.drawable.fanhui);  //设置左上角图标
        toolbar.setNavigationOnClickListener(view -> finish());  //退出
    }

    @Override
    public void loadData() {
        if(SharedPreferencesUtil.getBeanFromSp(this,Constant.FILE_NAME,Constant.DATA) != null){
            UserBean bean = SharedPreferencesUtil.getBeanFromSp(this,Constant.FILE_NAME,Constant.DATA);
            nickname.setText(bean.getContent().getName());
            sex.setText(bean.getContent().getSex());
            phone.setText(bean.getContent().getPhone());
        }
    }
}
